#include "SparseTable.h"
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
	int length;
	cin>>length;
	vector<double> mass;
	double current;
	for( int i = 0; i < length; i++ ) {
		scanf( "%lf", &current );
		mass.push_back( current );
	}
	SparseTable spt( mass );
	int M;
	cin>>M;
	int first, second;
	vector<double> results;
	for( int j = 0; j < M; j++ ) {
		cin>>first>>second;
		second--;
		results.push_back( spt.RMQ( first, second ) );
	}
	for( vector<double>::iterator it = results.begin(); it != results.end(); it++ ) {
		cout<<*it<<'\n';
	}
	return 0;
}